Byteazar the Dragon has piggy banks. Each piggy bank can either be opened with its corresponding key or smashed. Byteazar has put the keys in some of the piggy banks - he remembers which key has been placed in which piggy bank. Byteazar intends to buy a car and needs to gain access to all of the piggy banks. However, he wants to destroy as few of them as possible. Help Byteazar to determine how many piggy banks have to be smashed.
Task
Write a programme which:
reads from the standard input the number of piggy banks and the deployment of their corresponding keys,
finds the minimal number of piggy banks to be smashed in order to gain access to all of them,
writes the outcome to the standard output.
Input
The first line of the standard input contains a single integer () - this is the number of piggy banks owned by the dragon. The piggy banks (as well as their corresponding keys) are numbered from to . Next, there are lines: the 'st line contains a single integer - the number of the piggy bank in which the 'th key has been placed.
Output
The first and only line of the standard output should contain a single integer - the minimal number of piggy banks to be smashed in order to gain access to all of the piggy banks.
Example
For the input data:
4
2
1
2
4
the correct result is:
2
In the foregoing example piggy banks and have to be smashed.
Task author: Wojciech Guzicki.
Kontakt
W razie problemów technicznych ze Szkopułem, prosimy o kontakt mailowy pod adresem szkopul@fri.edu.pl.
Jeśli chciałbyś porozmawiać o zadaniach, rozwiązaniach lub problemach technicznych, odwiedź nasze serwery na Discordzie. Są one moderowane przez społeczność, ale członkowie zespołu wsparcia również aktywnie się tam udzielają.